package DoublePointer;

import org.junit.Test;

import java.util.Arrays;

/**
 * @BelongsProject: SeniorArchitect-LeetCode
 * @BelongsPackage: DoublePointer
 * @Author: zhuangxiaoyan
 * @CreateTime: 2023-11-03  17:30
 * @Description: TODO
 * @Version: 1.0
 */
public class 删除有序数组中重复元素26 {

    public int removeDuplicates(int[] nums) {
        int n = nums.length;
        if (n <= 1) {
            return n;
        }
        int slow = 1;
        int fast = 1;
        while (fast < n) {
            if (nums[slow - 1] != nums[fast]) {
                nums[slow] = nums[fast];
                ++slow;
            }
            ++fast;
        }
        return slow;
    }


    @Test
    public void test(){
        int i = removeDuplicates(new int[]{0,0,1,1,1,2,2,3,3,4});
    }
}
